{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60b7f9ad-5260-46e7-915b-11c47814c6e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install streamlit pandas lxml\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "05fc177c-b1e6-4b9b-8569-769b7fe5ddf9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import streamlit as st\n",
    "\n",
    "x = st.slider('Select a value')\n",
    "st.write(x, 'squared is', x * x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "c2498ac1-01dc-475a-b1d3-bad3743747db",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "table_MN = pd.read_html('https://www.swissmedic.ch/swissmedic/de/home/news/coronavirus-covid-19/covid-19-vaccines-safety-update-8.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "a6b44751-8448-48e7-b79a-b8dc6085d73a",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = table_MN[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "60371120-fc3c-4ffa-b1a2-d305d9254064",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "1aba4e2c-e165-4ae4-ba8c-034fa0107f13",
   "metadata": {},
   "outputs": [],
   "source": [
    "#df = df.fillna('0')\n",
    "df = df.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "0dfc4744-1ec4-46ee-b4e6-f57b08c681d9",
   "metadata": {},
   "outputs": [],
   "source": [
    "pre_process = lambda s: int(s.split(' ')[0].replace(\"'\",''))\n",
    "\n",
    "df['vaccine'] = df['Impfstoff']\n",
    "df['cases_total']=df['Verdachtsmeldungen insgesamt'].apply(pre_process)\n",
    "df['cases_non_severe']=df['davon nicht schwerwiegend'].apply(pre_process)\n",
    "df['cases_severe']=df['davon schwerwiegend'].apply(pre_process)\n",
    "df['vaccine_doses']=df['Total verabreichte Impfdosen *'].apply(pre_process)\n",
    "df['fully_vaccinated']=df['VollstÃ¤ndig geimpfte Personen *'].apply(pre_process)\n",
    "df['severe_probability']=df['fully_vaccinated']/df['cases_severe']\n",
    "df['severe_percenage']=100/df['severe_probability']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "57de1288-179e-4ffd-b996-b374027f9684",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.drop(['Impfstoff', 'Verdachtsmeldungen insgesamt','davon nicht schwerwiegend','davon schwerwiegend','Total verabreichte Impfdosen *','VollstÃ¤ndig geimpfte Personen *'], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "914f0cbd-2772-4c14-9d10-f07c1811894b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>vaccine</th>\n",
       "      <th>cases_total</th>\n",
       "      <th>cases_non_severe</th>\n",
       "      <th>cases_severe</th>\n",
       "      <th>vaccine_doses</th>\n",
       "      <th>fully_vaccinated</th>\n",
       "      <th>severe_probability</th>\n",
       "      <th>severe_percenage</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SpikevaxÂ® (Moderna)</td>\n",
       "      <td>6777</td>\n",
       "      <td>4662</td>\n",
       "      <td>2115</td>\n",
       "      <td>7291217</td>\n",
       "      <td>3642035</td>\n",
       "      <td>1722.002364</td>\n",
       "      <td>0.058072</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ComirnatyÂ® (Pfizer/BioNTech)</td>\n",
       "      <td>2835</td>\n",
       "      <td>1662</td>\n",
       "      <td>1173</td>\n",
       "      <td>3824485</td>\n",
       "      <td>1893728</td>\n",
       "      <td>1614.431373</td>\n",
       "      <td>0.061941</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>COVID-19 Vaccine Janssen</td>\n",
       "      <td>31</td>\n",
       "      <td>21</td>\n",
       "      <td>10</td>\n",
       "      <td>21787</td>\n",
       "      <td>21577</td>\n",
       "      <td>2157.700000</td>\n",
       "      <td>0.046346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Total</td>\n",
       "      <td>9834</td>\n",
       "      <td>6438</td>\n",
       "      <td>3396</td>\n",
       "      <td>11137489</td>\n",
       "      <td>5557340</td>\n",
       "      <td>1636.436985</td>\n",
       "      <td>0.061108</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         vaccine  cases_total  cases_non_severe  cases_severe  \\\n",
       "0           SpikevaxÂ® (Moderna)         6777              4662          2115   \n",
       "1  ComirnatyÂ® (Pfizer/BioNTech)         2835              1662          1173   \n",
       "2       COVID-19 Vaccine Janssen           31                21            10   \n",
       "4                          Total         9834              6438          3396   \n",
       "\n",
       "   vaccine_doses  fully_vaccinated  severe_probability  severe_percenage  \n",
       "0        7291217           3642035         1722.002364          0.058072  \n",
       "1        3824485           1893728         1614.431373          0.061941  \n",
       "2          21787             21577         2157.700000          0.046346  \n",
       "4       11137489           5557340         1636.436985          0.061108  "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "8e78ac6e-85df-4b25-8f9d-189bfa6c95cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv('data.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4daf7118-f2a4-42a4-a079-3fea2e267667",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
